package classes.web;
import org.junit.Test;

import java.io.*;
import java.net.*;

public class UDPReceiver {
    @Test
    public void test(){
        DatagramSocket socket = null;
        try {
            socket =new DatagramSocket(9999);
            byte[] bytes = new byte[1024];
            DatagramPacket dp = new DatagramPacket(bytes, bytes.length);
            socket.receive(dp);
            String str = new String(dp.getData(), 0, dp.getLength());
            System.out.println(str);
            System.out.println(dp.getAddress());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if(socket != null){
                socket.close();
            }
        }

    }
}
